package com.zeroxml.cms.service.impl;

import com.zeroxml.cms.dao.ICatalogDAO;
import com.zeroxml.cms.service.ICatalogService;
import com.zeroxml.cms.bo.Catalog;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

/**
 * User: cjp
 * Date: 2007-9-9
 * Time: 19:45:26
 */
@Transactional
public class CatalogService implements ICatalogService {
    private ICatalogDAO catalogDAO;

    public void setCatalogDAO(ICatalogDAO catalogDAO) {
        this.catalogDAO = catalogDAO;
    }

    public List<Catalog> getCatalogList(long parentId) {
        return catalogDAO.getCatalogList(parentId);
    }

    public Catalog getCatalog(long id) {
        return catalogDAO.getById(id);
    }

    public void updateCatalog(Catalog catalog) {
       catalogDAO.update(catalog);
    }

    public void createCatalog(Catalog catalog) {
        catalogDAO.create(catalog);
    }

    public void deleteCatalog(long id) {
        Catalog catalog=catalogDAO.getById(id);
        if(catalog!=null){
            catalog.setStatus(Catalog.STATUS_DELETE);
            catalogDAO.update(catalog);
        }
    }

    public Catalog getCatalog(String name) {
        return catalogDAO.getCatalog(name);
    }
}
